package b.b.h;

import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
import android.view.ViewParent;
import b.b.g.i.p;

/* compiled from: ForwardingListener */
public abstract class r implements OnTouchListener, OnAttachStateChangeListener {
    public final float a;
    public final int b;
    public final int c;
    public final View d;
    public Runnable e;
    public Runnable f;
    public boolean g;
    public int h;
    public final int[] i = new int[2];

    /* compiled from: ForwardingListener */
    public class a implements Runnable {
        public void run() {
            ViewParent parent = r.this.d.getParent();
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        }
    }

    /* compiled from: ForwardingListener */
    public class b implements Runnable {
        public void run() {
            r rVar = r.this;
            rVar.a();
            View view = rVar.d;
            if (view.isEnabled() && !view.isLongClickable() && rVar.c()) {
                view.getParent().requestDisallowInterceptTouchEvent(true);
                long uptimeMillis = SystemClock.uptimeMillis();
                MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0);
                view.onTouchEvent(obtain);
                obtain.recycle();
                rVar.g = true;
            }
        }
    }

    public r(View view) {
        this.d = view;
        view.setLongClickable(true);
        view.addOnAttachStateChangeListener(this);
        this.a = (float) ViewConfiguration.get(view.getContext()).getScaledTouchSlop();
        int tapTimeout = ViewConfiguration.getTapTimeout();
        this.b = tapTimeout;
        this.c = (ViewConfiguration.getLongPressTimeout() + tapTimeout) / 2;
    }

    public final void a() {
        Runnable runnable = this.f;
        if (runnable != null) {
            this.d.removeCallbacks(runnable);
        }
        runnable = this.e;
        if (runnable != null) {
            this.d.removeCallbacks(runnable);
        }
    }

    public abstract p b();

    public abstract boolean c();

    public boolean d() {
        p b = b();
        if (b != null && b.b()) {
            b.dismiss();
        }
        return true;
    }

    /* JADX WARNING: Removed duplicated region for block: B:61:0x0113  */
    /* JADX WARNING: Missing block: B:32:0x0087, code skipped:
            if (r4 != 3) goto L_0x0079;
     */
    public boolean onTouch(android.view.View r12, android.view.MotionEvent r13) {
        /*
        r11 = this;
        r12 = r11.g;
        r0 = 3;
        r1 = 0;
        r2 = 1;
        if (r12 == 0) goto L_0x0071;
    L_0x0007:
        r3 = r11.d;
        r4 = r11.b();
        if (r4 == 0) goto L_0x0061;
    L_0x000f:
        r5 = r4.b();
        if (r5 != 0) goto L_0x0016;
    L_0x0015:
        goto L_0x0061;
    L_0x0016:
        r4 = r4.g();
        r4 = (b.b.h.p) r4;
        if (r4 == 0) goto L_0x0061;
    L_0x001e:
        r5 = r4.isShown();
        if (r5 != 0) goto L_0x0025;
    L_0x0024:
        goto L_0x0061;
    L_0x0025:
        r5 = android.view.MotionEvent.obtainNoHistory(r13);
        r6 = r11.i;
        r3.getLocationOnScreen(r6);
        r3 = r6[r1];
        r3 = (float) r3;
        r6 = r6[r2];
        r6 = (float) r6;
        r5.offsetLocation(r3, r6);
        r3 = r11.i;
        r4.getLocationOnScreen(r3);
        r6 = r3[r1];
        r6 = -r6;
        r6 = (float) r6;
        r3 = r3[r2];
        r3 = -r3;
        r3 = (float) r3;
        r5.offsetLocation(r6, r3);
        r3 = r11.h;
        r3 = r4.b(r5, r3);
        r5.recycle();
        r13 = r13.getActionMasked();
        if (r13 == r2) goto L_0x005a;
    L_0x0056:
        if (r13 == r0) goto L_0x005a;
    L_0x0058:
        r13 = 1;
        goto L_0x005b;
    L_0x005a:
        r13 = 0;
    L_0x005b:
        if (r3 == 0) goto L_0x0061;
    L_0x005d:
        if (r13 == 0) goto L_0x0061;
    L_0x005f:
        r13 = 1;
        goto L_0x0062;
    L_0x0061:
        r13 = 0;
    L_0x0062:
        if (r13 != 0) goto L_0x006e;
    L_0x0064:
        r13 = r11.d();
        if (r13 != 0) goto L_0x006b;
    L_0x006a:
        goto L_0x006e;
    L_0x006b:
        r13 = 0;
        goto L_0x0128;
    L_0x006e:
        r13 = 1;
        goto L_0x0128;
    L_0x0071:
        r3 = r11.d;
        r4 = r3.isEnabled();
        if (r4 != 0) goto L_0x007c;
    L_0x0079:
        r13 = 0;
        goto L_0x0106;
    L_0x007c:
        r4 = r13.getActionMasked();
        if (r4 == 0) goto L_0x00d8;
    L_0x0082:
        if (r4 == r2) goto L_0x00d4;
    L_0x0084:
        r5 = 2;
        if (r4 == r5) goto L_0x008a;
    L_0x0087:
        if (r4 == r0) goto L_0x00d4;
    L_0x0089:
        goto L_0x0079;
    L_0x008a:
        r0 = r11.h;
        r0 = r13.findPointerIndex(r0);
        if (r0 < 0) goto L_0x0079;
    L_0x0092:
        r4 = r13.getX(r0);
        r13 = r13.getY(r0);
        r0 = r11.a;
        r5 = -r0;
        r6 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1));
        if (r6 < 0) goto L_0x00c5;
    L_0x00a1:
        r5 = (r13 > r5 ? 1 : (r13 == r5 ? 0 : -1));
        if (r5 < 0) goto L_0x00c5;
    L_0x00a5:
        r5 = r3.getRight();
        r6 = r3.getLeft();
        r5 = r5 - r6;
        r5 = (float) r5;
        r5 = r5 + r0;
        r4 = (r4 > r5 ? 1 : (r4 == r5 ? 0 : -1));
        if (r4 >= 0) goto L_0x00c5;
    L_0x00b4:
        r4 = r3.getBottom();
        r5 = r3.getTop();
        r4 = r4 - r5;
        r4 = (float) r4;
        r4 = r4 + r0;
        r13 = (r13 > r4 ? 1 : (r13 == r4 ? 0 : -1));
        if (r13 >= 0) goto L_0x00c5;
    L_0x00c3:
        r13 = 1;
        goto L_0x00c6;
    L_0x00c5:
        r13 = 0;
    L_0x00c6:
        if (r13 != 0) goto L_0x0079;
    L_0x00c8:
        r11.a();
        r13 = r3.getParent();
        r13.requestDisallowInterceptTouchEvent(r2);
        r13 = 1;
        goto L_0x0106;
    L_0x00d4:
        r11.a();
        goto L_0x0079;
    L_0x00d8:
        r13 = r13.getPointerId(r1);
        r11.h = r13;
        r13 = r11.e;
        if (r13 != 0) goto L_0x00e9;
    L_0x00e2:
        r13 = new b.b.h.r$a;
        r13.m348init();
        r11.e = r13;
    L_0x00e9:
        r13 = r11.e;
        r0 = r11.b;
        r4 = (long) r0;
        r3.postDelayed(r13, r4);
        r13 = r11.f;
        if (r13 != 0) goto L_0x00fc;
    L_0x00f5:
        r13 = new b.b.h.r$b;
        r13.m349init();
        r11.f = r13;
    L_0x00fc:
        r13 = r11.f;
        r0 = r11.c;
        r4 = (long) r0;
        r3.postDelayed(r13, r4);
        goto L_0x0079;
    L_0x0106:
        if (r13 == 0) goto L_0x0110;
    L_0x0108:
        r13 = r11.c();
        if (r13 == 0) goto L_0x0110;
    L_0x010e:
        r13 = 1;
        goto L_0x0111;
    L_0x0110:
        r13 = 0;
    L_0x0111:
        if (r13 == 0) goto L_0x0128;
    L_0x0113:
        r5 = android.os.SystemClock.uptimeMillis();
        r7 = 3;
        r8 = 0;
        r9 = 0;
        r10 = 0;
        r3 = r5;
        r0 = android.view.MotionEvent.obtain(r3, r5, r7, r8, r9, r10);
        r3 = r11.d;
        r3.onTouchEvent(r0);
        r0.recycle();
    L_0x0128:
        r11.g = r13;
        if (r13 != 0) goto L_0x012e;
    L_0x012c:
        if (r12 == 0) goto L_0x012f;
    L_0x012e:
        r1 = 1;
    L_0x012f:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.b.h.r.onTouch(android.view.View, android.view.MotionEvent):boolean");
    }

    public void onViewAttachedToWindow(View view) {
    }

    public void onViewDetachedFromWindow(View view) {
        this.g = false;
        this.h = -1;
        Runnable runnable = this.e;
        if (runnable != null) {
            this.d.removeCallbacks(runnable);
        }
    }
}
